package com.tbit.uqbike.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;

/**
 * 坏账处理类型
 *
 *
 * @author <a href="mailto:chen.chaoxiong@tbit.com.cn">ChenChaoXiong</a>
 * @since 2024/5/21
 */
public enum BadOrderHandleType {

    HANDLED("processed", 1, "已处理"),
    UNHANDLE("unprocessed", 2, "未处理");

    private final String type;

    @EnumValue
    private final Integer code;

    private final String desc;

    BadOrderHandleType(String type, Integer code, String desc) {
        this.type = type;
        this.code = code;
        this.desc = desc;
    }

    public String getType() {
        return type;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return type;
    }

    public static Integer getCodeByType(String type) {
        for (BadOrderHandleType handleType : values()) {
            if (handleType.getType().equals(type)) {
                return handleType.getCode();
            }
        }
        return null;
    }

    public static String getDescByType(String type) {
        for (BadOrderHandleType handleType : values()) {
            if (handleType.getType().equals(type)) {
                return handleType.getDesc();
            }
        }
        return null;
    }

    public static String getTypeByDesc(String desc) {
        for (BadOrderHandleType handleType : values()) {
            if (handleType.getDesc().equals(desc)) {
                return handleType.getType();
            }
        }
        return null;
    }
}